package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.DianpuBean;
import com.lwj.liwanjia.impl.DianpuView;
import com.lwj.liwanjia.model.DianpuModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/11.
 */

public class DianpuPresenter {
    private DianpuView dianpuView;
    private DianpuModel dianpuModel;

    public DianpuPresenter(DianpuView dianpuView) {
        this.dianpuView = dianpuView;
        dianpuModel = new DianpuModel();
    }

    public void getDianpuData(String token, int shopInfoId) {
        if (dianpuView != null) {
            dianpuModel.getDianpuData(token, shopInfoId, new Subscriber<DianpuBean>() {
                @Override
                public void onCompleted() {
                }

                @Override
                public void onError(Throwable e) {
                    dianpuView.showError((Exception) e);
                }

                @Override
                public void onNext(DianpuBean dianpuBean) {
                    dianpuView.getDianpuData(dianpuBean);
                }
            });
        }
    }
}
